package com.qfedu.knowledge.entity.bo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.qfedu.knowledge.entity.dto.ImportQuestionDTO;
import com.qfedu.knowledge.entity.dto.QuestionInfoDTO;
import com.qfedu.knowledge.entity.enums.SourceEnum;
import lombok.*;

/**
 * @ClassName QuestionInfo
 * @Author ykx
 * @Date 2024/1/3 9:52
 * @Version 1.0
 */
@EqualsAndHashCode(callSuper = false)
@TableName("kn_question_info_t")
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class QuestionInfoBO extends BaseColumn {

    /**
     * 主键id
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 编码
     */
    @TableField("code")
    private String code;

    /**
     * 来源
     */
    @TableField("source")
    private Integer source;

    /**
     * 题目
     */
    @TableField("question")
    private String question;

    /**
     * 选项A
     */
    @TableField("option_a")
    private String optionA;

    /**
     * 选项B
     */
    @TableField("option_b")
    private String optionB;

    /**
     * 选项C
     */
    @TableField("option_c")
    private String optionC;

    /**
     * 选项D
     */
    @TableField("option_d")
    private String optionD;

    /**
     * 答案选项
     */
    @TableField("answer_option")
    private String answerOption;

    /**
     * 答案
     */
    @TableField("answer")
    private String answer;

    /**
     * 备注
     */
    @TableField("remark")
    private String remark;

    /**
     * 类型
     */
    @TableField("type")
    private Integer type;

    /**
     * 构建QuestionInfoBO
     *
     * @param questionInfoDTO questionInfoDTO
     * @return QuestionInfoBO
     */
    public static QuestionInfoBO BuildQuestion(QuestionInfoDTO questionInfoDTO) {
        return QuestionInfoBO.builder()
                .id(questionInfoDTO.getId())
                .question(questionInfoDTO.getQuestion())
                .answer(questionInfoDTO.getAnswer())
                .answerOption(questionInfoDTO.getAnswerOption())
                .optionA(questionInfoDTO.getOptionA())
                .optionB(questionInfoDTO.getOptionB())
                .optionC(questionInfoDTO.getOptionC())
                .optionD(questionInfoDTO.getOptionD())
                .type(questionInfoDTO.getType())
                .build();
    }

    public static QuestionInfoBO BuildQuestion(ImportQuestionDTO importQuestionDTO) {
        return QuestionInfoBO.builder()
                .code(importQuestionDTO.getCode())
                .type(importQuestionDTO.getType())
                .source(SourceEnum.STAND.getCode())
                .question(importQuestionDTO.getQuestion())
                .optionA(importQuestionDTO.getOptionA())
                .optionB(importQuestionDTO.getOptionB())
                .optionC(importQuestionDTO.getOptionC())
                .optionD(importQuestionDTO.getOptionD())
                .answerOption(importQuestionDTO.getAnswerOption())
                .build();
    }

}
